﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Labthink.PCSoft.UniversalHost4.Instrument.MyControls
{
    /// <summary>
    /// UcSearchBox.xaml 的交互逻辑
    /// </summary>
    public partial class UcSearchBox : UserControl
    {
        public UcSearchBox()
        {
            InitializeComponent();
        }

        public event EventHandler<SearchEventArgs> OnSearch;
        private void BtnSearch_OnClick(object sender, RoutedEventArgs e)
        {
            ExeccuteSearch();
        }

       

        private void ExeccuteSearch()
        {
            if (OnSearch != null)
            {
                var args = new SearchEventArgs
                {
                    SearchText = txtUserID.Text
                };
                OnSearch(this, args);
            }
        }

        private void UcSearchBox_OnKeyDown(object sender, KeyEventArgs e)
        {
            if(e.Key == Key.Enter) ExeccuteSearch();
        }
    }

    public class SearchEventArgs : EventArgs
    {
        public string SearchText { get; set; }
    }
}
